//package com.levi.mqtt;
//
//import org.eclipse.paho.client.mqttv3.MqttClient;
//import org.eclipse.paho.client.mqttv3.MqttException;
//import org.eclipse.paho.client.mqttv3.MqttMessage;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.web.bind.annotation.PostMapping;
//
//import javax.annotation.PostConstruct;
//import java.nio.charset.StandardCharsets;
//
///**
// * @author shentong
// * @since 2022/9/12 22:13
// */
//@Service
//public class MqttService {
//
//	@Autowired
//	private MqttClient mqttClient;
//
//    @PostConstruct
//    public void init() {
//        mqttClient.setCallback(new OnMessageCallback());
//	}
//
//    public String send() throws MqttException {
//        MqttMessage mqttMessage = new MqttMessage("hello,spring".getBytes(StandardCharsets.UTF_8));
//        mqttClient.publish("testtopic/2", mqttMessage);
//        return "success";
//    }
//}
